// pages/newmarkmine/newmarkmine.js
import https from '../../utils/newrequest'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        type: 2,
        endstartlist: [],
        list: [],
        markingPapers: false,
        carryOutFlag: false,
        examlist: [],
        page: 1,
        pageSize: 10,
        isLoading: false,
        isEnd: false,
        isError: false,
        dataType: 1,
        examEndlist: []
    },
    changeState(e) {
        let index = e.currentTarget.dataset.index
        this.setData({
            carryOutFlag: !this.data.carryOutFlag,
            dataType: index
        })
        this.isLoading = false
        if (index==2) {
            // this.endmytasks()
            this.endExamproject()
        }
    },
    //获取项目列表
    async getexamContent() {
        let { page, pageSize } = this.data
        let options = {
            url: '/task/teacher/stats/myProject',
            method: 'get',
            data: { pageNum:page,pageSize:pageSize,stopped:0 },
            header: { "content-type": "application/json;charset=UTF-8" }
        }
        let res = await https(options)
        if (res.data.code == 200) {
            this.setData({
                examlist: res.data.data || [],
            })
        } else {
            this.setData({ isError: true })
        }
    },
    jumppage1(e) {
        wx.setStorageSync('newdataObj', JSON.stringify(e.currentTarget.dataset.item))
        wx.navigateTo({
            url: '/pages/newmarkinglist/newmarkinglist',
        })
    },
    jumppage(e) {
        let id = e.currentTarget.dataset.id
        if (id != null) {

        }
        this.setData({
            type: e.currentTarget.dataset.item.n4type
        })
        if (!this.data.markingPapers) {
            let obj = {
                n4: e.currentTarget.dataset.item.nav4Id,
                n5: e.currentTarget.dataset.item.oldExamId,
                type: e.currentTarget.dataset.item.n4type,
                title: e.currentTarget.dataset.item.title,
                createdata: e.currentTarget.dataset.item.createdate,
                groupid: e.currentTarget.dataset.item.groupId,
            }
            wx.setStorageSync('alaynisData', JSON.stringify(obj))
        }
        if (id == 1) {
            if (id == 1 && this.data.markingPapers) {
                // 跳转阅卷
                wx.navigateTo({
                    url: '/pages/newmarkinglist/newmarkinglist',
                })
            } else {
                wx.showToast({
                    title: '当前进度不可使用该功能!',
                    icon: "none"
                })
            }
        }
        if (id == 2) {
            if (id == 2 && e.currentTarget.dataset.item.selectScoreType != 0) {
                // 跳转成绩单
                wx.navigateTo({
                    url: '/pages/selecttranscript/selecttranscript',
                })
            } else {
                wx.showToast({
                    title: '该时间无法查看成绩单,请根据通知时间查看!',
                    icon: "none"
                })
            }
        }
        if (id == 3) {
            if (id == 3 && e.currentTarget.dataset.item.selectScoreType != 0) {
                // 跳转成绩分析
                wx.navigateTo({
                    url: '/pages/selecttranscripts/selecttranscripts',
                })
            } else {
                wx.showToast({
                    title: '该时间无法查看成绩分析,请根据通知时间查看!',
                    icon: "none"
                })
            }
        }
    },
    // 已结束的项目
    async endExamproject() {
        let options = {
            url: '/system/exam/main/list/by/teacher',
            method: 'get',
            header: { "content-type": "application/json;charset=UTF-8" }
        }
        let res = await https(options)
        this.setData({ examEndlist: res.data.rows })
        this.isLoading = false
        this.isEnd = false
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.getexamContent()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },
    onRetry() {
    }
})